<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<center>
		<table>
			<tr>
				<td>用户名:</td>
				<td><input type="text" name="u_name" id="u_name"></td>
			</tr>
			<tr>
				<td>密码:</td>
				<td><input type="password" name="u_pwd" id="u_pwd"></td>
			</tr>
			<tr>
				<td>手机号:</td>
				<td><input type="text" name="u_tel" id="u_tel"></td>
				<td><button id="hq">获取验证码</button></td>
			</tr>
			<tr>
				<td>验证码:</td>
				<td><input type="text" name="code" id="code"></td>
			</tr>
			<tr>
				<td><button id="send">注册</button></td>
			</tr>
		</table>
	</center>
</body>
</html>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
//发送验证码
	$(document).on("click","#hq",function(){

		var u_tel=$("#u_tel").val();
		if(u_tel=="")
		{
          alert("手机号不可以为空");
          return false;
		}
		$.ajax({

			url:"SendTemplateSMS.php",
			type:"post",
			data:{u_tel:u_tel},
			success:function(res){
				console.log(res);
			}
		})
	})
	//注册
		$(document).on("click","#send",function(){

		var u_tel=$("#u_tel").val();
		var u_name=$("#u_name").val();
		var u_pwd=$("#u_pwd").val();
		var code=$("#code").val();
		if(u_name=="")
		{
          alert("用户名不可以为空");
          return false;
		}
		if(u_pwd.length<8 ||u_pwd.length>16)
		{
           alert("密码必须为8-16位");
           return false;
		}
		$.ajax({

			url:"mm.php",
			type:"post",
			dataType:"json",
			data:{u_tel:u_tel,u_name:u_name,u_pwd:u_pwd,code:code},
			success:function(res){
				alert(res.msg);
				location.href="dl.html";
			}
		})
	})
</script>